<?php

$item = '';

if (isset($source_item)) { // exsit item
  $source_item_id = $source_item['id'];
  $title_xpath = $source_item['title_xpath'];
  $content_xpath = $source_item['content_xpath'];
  $image_xpath = $source_item['image_xpath'];
  $href_xpath = $source_item['href_xpath'];
  $form_target = 'update_item';

} else { // new item
  $source_item_id = '';
  $title_xpath = '';
  $content_xpath = '';
  $image_xpath = 'true';
  $href_xpath = '';
  $form_target = 'add_item';

  $item .= '
  第一参数最小值:<input name="wild_low1" size="2" value="1"> 
第一参数最大值:<input name="wild_high1" size="2" value="1">
第一参数递增:<input name="wild_delta1" size="2" value="1">
<br/><br/>
第二参数最小值:<input name="wild_low2" size="2" value="1">
第二参数最大值:<input name="wild_high2" size="2" value="1">
第二参数递增:<input name="wild_delta2" size="2" value="1"> <br/><br/>';

}



$item .= sprintf('<input type="hidden" name="item_id" value="%s" />',
                 $source_item_id);
$item .= sprintf('标题：<input name="title_xpath" class="xpath_input" value="%s" /><br/>',
                 htmlentities($title_xpath, ENT_QUOTES, 'UTF-8'));
$item .= sprintf('内容：<input name="content_xpath" class="xpath_input" value="%s" /><br/>',
                 htmlentities($content_xpath, ENT_QUOTES, 'UTF-8'));
$item .= sprintf('图片：<input name="image_xpath" class="xpath_input" value="%s" /><br/>',
                 htmlentities($image_xpath, ENT_QUOTES, 'UTF-8'));
$item .= sprintf('连接：<input name="href_xpath" class="xpath_input" value="%s" />',
                 htmlentities($href_xpath, ENT_QUOTES, 'UTF-8'));


$item .= '<a href="javascript:void(0)" onclick="update_source_item(this)">更新</a>';
$item .= '<a href="javascript:void(0)" onclick="remove_source_item(this)">删除</a>';
$item .= '<a href="javascript:void(0)" onclick="test_source_item(this)">测试<img src="res/loading.gif" class="loading" /></a>';

echo sprintf("<li class='item-detail'><form action='index.php?op=%s' class='item-form' method='post'>%s</form></li>",
             $form_target, $item);
?>